package com.seven.sevenchat.once;
import java.util.Date;

import com.seven.sevenchat.mapper.UserMapper;
import com.seven.sevenchat.model.User;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
import javax.annotation.Resource;

@Component
public class InsertUser {

    @Resource
    private UserMapper userMapper;

    //循环插入用户
    public void doInsertUser() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUM = 1000;
        for (int i = 0; i < INSERT_NUM; i++) {
            User user = new User();
            user.setId(0L);
            user.setUsername("");
            user.setPhoto("");
            user.setGender(0);
            user.setPassword("");
            user.setPhone("");
            user.setEmail("");
            user.setUserStatus(0);
            user.setCreateTime(new Date());
            user.setUpdateTime(new Date());
            user.setIsDelete(0);
            user.setRole(0);
            user.setPlanetCode("");
            user.setTag("");
            userMapper.insert(user);
        }
        stopWatch.stop();
        System.out.println( stopWatch.getLastTaskTimeMillis());

    }
}
